package com.base.common;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具类
 * @author 私奔
 * @param <T>
 */
public class Page<T> implements Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 246657941450909663L;
	private int pageNumber = Constants.DEFAULT_PAGENUMBER;//当前页
	private int pageSize = Constants.DEFAULT_PAGESIZE;//每页大小
	private int totalPage;//总页数
	private int totalRow;//总数据行数
	private int startRow;//查询数据起始行
	private int endRow;//查询数据结束行
	private List<T> result;

	public boolean isFirstPage() {
		return pageNumber == 1;
	}

	public boolean isLastPage() {
		return pageNumber == totalPage;
	}

	public Page(int pageNumber, int pageSize, int totalPage, int totalRow, int startRow, int endRow, List<T> result) {
		this.pageNumber = pageNumber;
		this.pageSize = pageSize;
		this.totalPage = totalPage;
		this.totalRow = totalRow;
		this.startRow = startRow;
		this.endRow = endRow;
		this.result = result;
	}

	public Page(int pageNumber, int pageSize, List<T> result) {
		this.pageNumber = pageNumber;
		this.pageSize = pageSize;
		this.result = result;
	}

	public Page(List<T> result) {
		this(Constants.DEFAULT_PAGENUMBER, Constants.DEFAULT_PAGESIZE, result);
	}

	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalRow() {
		return totalRow;
	}

	public void setTotalRow(int totalRow) {
		this.totalRow = totalRow;
	}

	public int getStartRow() {
		return startRow;
	}

	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}

	public int getEndRow() {
		return endRow;
	}

	public void setEndRow(int endRow) {
		this.endRow = endRow;
	}

	public List<T> getResult() {
		return result;
	}

	public void setResult(List<T> result) {
		this.result = result;
	}

}
